package com.guoheng.hazard.sys.controller.wuZhongData;

import com.guoheng.hazard.sys.model.dto.wuZhongData.WoZhongTankDataDTO;
import com.guoheng.hazard.sys.model.dto.wuZhongData.WoZhongTankHistoryDataDTO;
import com.guoheng.hazard.sys.service.wuZhongData.WuZhongDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @program: cespimp-hazard-server
 * @description:
 * @author: fbl
 * @create: 2020-03-27 15:40
 **/
@RestController
@Validated
@Api(value = "吴中数据对接接口")
public class WuZhongDataController {

    @Autowired
    WuZhongDataService wuZhongDataService;

    @ApiOperation(value = "查询某个储罐上传感器实时信息")
    @GetMapping(value = "api/v2/safety/real-data")
    public WoZhongTankDataDTO getTankSensorData(@RequestParam("tankId") String tankId, @RequestParam("companyId") String companyId) throws Exception {
        return wuZhongDataService.getTankSensorData(tankId, companyId);
    }

    @ApiOperation(value = "获取传感器历史数据")
    @GetMapping(value = "api/v2/safety/history-data")
    public WoZhongTankHistoryDataDTO getSensorHistoryData(String beginTime, String endTime, @RequestParam("sensorId") String sensorId, @RequestParam("tankId") String tankId, @RequestParam("companyId") String companyId) throws Exception {
        return wuZhongDataService.getSensorHistoryData(beginTime, endTime, sensorId, tankId, companyId);
    }

    @ApiOperation(value = "获取传感器实时报警数据")
    @GetMapping(value = "api/v2/safety/real-alarm")
    public HashMap<String, Object> getSensorAlarmData(@RequestParam("sensorId") String sensorId, @RequestParam("tankId")String tankId, @RequestParam("companyId")String companyId) throws Exception {
        return wuZhongDataService.getSensorAlarmData(sensorId, tankId, companyId);
    }

    @ApiOperation(value = "获取传感器历史报警数据")
    @GetMapping(value = "api/v2/safety/history-alarm")
    public HashMap<String, Object> getSensorHistoryAlarmData(@RequestParam("companyCode") String companyCode, String beginTime, String endTime) throws Exception {
        HashMap<String, Object> sensorHistoryAlarmData = wuZhongDataService.getSensorHistoryAlarmData(companyCode, beginTime, endTime);
        return sensorHistoryAlarmData;
    }
}
